package com.demo.aop.exception;

import org.springframework.aop.framework.ProxyFactory;

/**
 * 描述：代理实现异常的层级处理
 *
 * @author lida
 * @time 2019/10/23 10:49
 */
public class ExceptionDemo {

	public static void main(String[] args) {
		ExceptionBean target = new ExceptionBean();
		ExceptionInterceptor advice = new ExceptionInterceptor();

		//代理
		ProxyFactory proxyFactory = new ProxyFactory();
		proxyFactory.addAdvice(advice);
		proxyFactory.setTarget(target);

		ExceptionBean proxy = (ExceptionBean)proxyFactory.getProxy();
		try {
			proxy.exception();
		} catch (Exception ignored) {
		}
		try {
			proxy.exceptionInterruption();
		} catch (Exception ignored) {
		}
	}
}
